/*
 *@description:日志管理
 *@Author:@reynold
 *@Date:2025-03-22 11:08:49
 *@Update:2025-03-22 11:08:49
 *@Version: V1.0.0
*/
<template>
  <Card>
    <div class="log_box">
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column type="index" :index="initIndex()" label="序号" width="100"></el-table-column>
        <el-table-column
          prop="realName"
          label="访问人真实姓名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="visitMethod"
          label="访问方式">
        </el-table-column>
        <el-table-column
          prop="visitUrl"
          label="访问路径">
        </el-table-column>
        <el-table-column
          prop="time"
          label="访问时间">
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageQuery.pageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageQuery.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </Card>
</template>

<script>
import Card from '@/components/Card/index.vue'
import instance from '@/utils/instance.js'
export default {
  data(){
    return{
      tableData:[],
      pageQuery:{
        pageNum:1,
        pageSize:10
      },
      total:10
    }
  },
  methods:{
    // 初始序号
    initIndex(){
      return (this.pageQuery.pageNum - 1) * this.pageQuery.pageSize + 1
    },
    // 获取日志管理数据
    getLogList(){
      instance.post('/log/list',this.pageQuery).then(res=>{
        this.tableData = res.data
        this.total = res.data.total
      })
    },
    handleSizeChange(val) {
      this.pageQuery.pageSize = val
      this.getLogList()
    },
    handleCurrentChange(val) {
      this.pageQuery.pageNum = val
      this.getLogList()
    }
  },
  created(){
    this.getLogList()
  },
  components:{
    Card
  }
}
</script>

<style lang="less" scoped>

</style>